package com.steven.im.ui.activity;

import android.content.Intent;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;

import com.steven.im.R;
import com.steven.im.base.BaseActivity;
import com.steven.im.utils.ScreenUtil;
import com.steven.im.utils.TitleBuilder;

import butterknife.BindView;
import butterknife.OnClick;


public class IMChangeNikeNameActivity extends BaseActivity {
    @BindView(R.id.iv_title_right)
    ImageView ivTitleRight;
    @BindView(R.id.etNickname)
    EditText etNickname;

    @Override
    public void setListen() {

    }

    @Override
    public void setTitleBarColor() {
        ivTitleRight.setVisibility(View.GONE);
        new TitleBuilder(this).setTitleText(getString(R.string.setNikeName))
                .setRightText(getString(R.string.done))
                .setLeftIcoListening(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        finish();
                    }
                });


    }

    @Override
    public int intiLayout() {
        return R.layout.activity_im_changenikename;
    }

    @Override
    public void initView() {

    }

    @OnClick({R.id.tv_title_right})
    public void onViewClicked(View view) {
        if (ScreenUtil.isFastClick()) {
            return;
        }
        switch (view.getId()) {
            case R.id.tv_title_right://完成
                if (etNickname.getText().toString().length() > 0) {
                    Intent it = new Intent();
                    it.putExtra("nickname", etNickname.getText().toString().trim());
                    setResult(RESULT_OK, it);
                }
                finish();
                break;
        }
    }

    @Override
    public void initData() {
        String nickname = getIntent().getStringExtra("nickname");
        etNickname.setText(nickname);
        assert nickname != null;
        etNickname.setSelection(nickname.length());
    }
}
